package com.mybatis;

import com.mybatis.dao.UserDao;
import com.mybatis.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceI {

    @Autowired
    private UserDao ud;

    public List<User> findUser(User u){
        return ud.findUser(u);
    }

    public List<User> findUser02(){
        return ud.findUser02(1.50D,1.72D);
    }

    public List<User> likeUser(String userName){
        return ud.likeUser(userName);
    }

    public String addUser01(User u){
        int i = ud.addUser01(u);
        return "数据新增"+(i>0?"成功":"失败");
    }

    public String batchAddUser(List<User> list){
        int i = ud.batchAddUser(list);
        return "数据批量新增"+(i>0?"成功":"失败");
    }

    public String editUser(User u){
        int i = ud.editUser(u);
        return "数据更新"+(i>0?"成功":"失败");
    }

    public String removeUser(int id){
        int i = ud.removeUser(id);
        return (i>0?"成功删除"+i+"条数据":"删除失败");
    }

    public String batchRemoveUser(List<Integer> list){
        int i = ud.batchRemoveUser(list);
        return (i>0?"成功删除"+i+"条数据":"删除失败");
    }

}
